﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class provider_Provider : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.UserAgent.IndexOf("AppleWebKit") > 0)
        {
            Request.Browser.Adapters.Clear();
        }

        //if (Session[CE.Global.General.Guest] == null)
        //{
        //    Response.Redirect("~/Default.aspx");
        //}
        //else if (Session[CE.Global.General.Guest].ToString() == "Provider")
        //{
        //    if (Session[CE.Global.General.UserId] == null)
        //    {
        //        Response.Redirect("~/Provider/ProviderSecureLogin.aspx");
        //    }
        //}
        if (Session[CE.Global.General.ProviderCompanyId] != null)
        {
            if (Session[CE.Global.General.ProviderCompanyId].ToString() == CE.Configuration.MyConfigurationManager.GetAppSettingValue("TH.LMGProviderCompanyId"))
            {
                imgLogo.ImageUrl = "~/Provider/images/logos/LMG_insurance.gif";
                imgLogo.ToolTip = "LMG Insurance";
                imgLogo.AlternateText = "LiMG Insurance";
                DateTime _dtLastLoginTime = Convert.ToDateTime(Session[CE.Global.General.LastLoginTime].ToString());
                divProviderInfo.InnerHtml = "Welcome " + Session[CE.Global.General.UserName].ToString() + ", LMG Insurance Thailand<br /><span>Last login date : " + _dtLastLoginTime.ToShortDateString() + " " + _dtLastLoginTime.ToShortTimeString() + "</span>";

                litTitlePage.Text = "LMG Insurance";

            }
            else if (Session[CE.Global.General.ProviderCompanyId].ToString() == CE.Configuration.MyConfigurationManager.GetAppSettingValue("TH.MSIGProviderCompanyId"))
            {
                imgLogo.ImageUrl = "~/Provider/images/logos/MSIG.gif";
                imgLogo.ToolTip = "MSIG Insurance";
                imgLogo.AlternateText = "MSIG Insurance";
                DateTime _dtLastLoginTime = Convert.ToDateTime(Session[CE.Global.General.LastLoginTime].ToString());
                divProviderInfo.InnerHtml = "Welcome " + Session[CE.Global.General.UserName].ToString() + ", MSIG Insurance Thailand<br /><span>Last login date : " + _dtLastLoginTime.ToShortDateString() + " " + _dtLastLoginTime.ToShortTimeString() + "</span>";
                
                litTitlePage.Text = "MSIG Insurance";
            }
            else if (Session[CE.Global.General.ProviderCompanyId].ToString() == CE.Configuration.MyConfigurationManager.GetAppSettingValue("TH.AZCpProviderCompanyId"))
            {
                imgLogo.ImageUrl = "~/Provider/images/logos/AZCp.gif";
                imgLogo.ToolTip = "Allianz CP Insurance";
                imgLogo.AlternateText = "Allianz CP Insurance";
                DateTime _dtLastLoginTime = Convert.ToDateTime(Session[CE.Global.General.LastLoginTime].ToString());
                divProviderInfo.InnerHtml = "Welcome " + Session[CE.Global.General.UserName].ToString() + ", Allianz CP Insurance Thailand<br /><span>Last login date : " + _dtLastLoginTime.ToShortDateString() + " " + _dtLastLoginTime.ToShortTimeString() + "</span>";

                litTitlePage.Text = "Allianz CP Insurance";
            }
            else if (Session[CE.Global.General.ProviderCompanyId].ToString() == CE.Configuration.MyConfigurationManager.GetAppSettingValue("TH.BKIProviderCompanyId"))
            {
                imgLogo.ImageUrl = "~/Provider/images/logos/bki.gif";
                imgLogo.ToolTip = "Bangkok Insurance";
                imgLogo.AlternateText = "Bangkok Insurance";
                DateTime _dtLastLoginTime = Convert.ToDateTime(Session[CE.Global.General.LastLoginTime].ToString());
                divProviderInfo.InnerHtml = "Welcome " + Session[CE.Global.General.UserName].ToString() + ", Bangkok Insurance Thailand<br /><span>Last login date : " + _dtLastLoginTime.ToShortDateString() + " " + _dtLastLoginTime.ToShortTimeString() + "</span>";
                
                litTitlePage.Text = "Bangkok Insurance";
            }
            else if (Session[CE.Global.General.ProviderCompanyId].ToString() == CE.Configuration.MyConfigurationManager.GetAppSettingValue("TH.ChartisProviderCompanyId"))
            {
                imgLogo.ImageUrl = "~/Provider/images/logos/chartis.gif";
                imgLogo.ToolTip = "Chartis Insurance";
                imgLogo.AlternateText = "Chartis Insurance";
                DateTime _dtLastLoginTime = Convert.ToDateTime(Session[CE.Global.General.LastLoginTime].ToString());
                divProviderInfo.InnerHtml = "Welcome " + Session[CE.Global.General.UserName].ToString() + ", Chartis Insurance Thailand<br /><span>Last login date : " + _dtLastLoginTime.ToShortDateString() + " " + _dtLastLoginTime.ToShortTimeString() + "</span>";

                litTitlePage.Text = "Chartis Insurance";
            }
            //else if (Session[CE.Global.General.ProviderCompanyId].ToString() == CE.Configuration.MyConfigurationManager.GetAppSettingValue("TH.ChartisProviderCompanyId"))
            //{
            //    imgLogo.ImageUrl = "~/Provider/images/logos/chartis.gif";
            //    imgLogo.ToolTip = "Chartis Insurance";
            //    imgLogo.AlternateText = "Chartis Insurance";

            //    DateTime _dtLastLoginTime = Convert.ToDateTime(Session[CE.Global.General.LastLoginTime].ToString());
            //    divProviderInfo.InnerHtml = "Welcome " + Session[CE.Global.General.UserName].ToString() + ", Chartis Insurance Thailand<br /><span>Last login date : " + _dtLastLoginTime.ToShortDateString() + " " + _dtLastLoginTime.ToShortTimeString() + "</span>";

            //    litTitlePage.Text = "Chartis Insurance";
            //}
            //else if (Session[CE.Global.General.ProviderCompanyId].ToString() == CE.Configuration.MyConfigurationManager.GetAppSettingValue("TH.HSBCProviderCompanyId"))
            //{
            //    imgLogo.ImageUrl = "~/Provider/images/logos/logo-hsbc.gif";
            //    imgLogo.ToolTip = "HSBC Insurance";
            //    imgLogo.AlternateText = "HSBC Insurance";

            //    DateTime _dtLastLoginTime = Convert.ToDateTime(Session[CE.Global.General.LastLoginTime].ToString());
            //    divProviderInfo.InnerHtml = "Welcome " + Session[CE.Global.General.UserName].ToString() + ", HSBC Insurance Thailand<br /><span>Last login date : " + _dtLastLoginTime.ToShortDateString() + " " + _dtLastLoginTime.ToShortTimeString() + "</span>";
                
            //    litTitlePage.Text = "HSBC Insurance";
            //}
            else
            {
                imgLogo.Visible = false;
                divProviderInfo.InnerHtml = "No such provider company found.";
                litTitlePage.Text = "No such provider company found.";
            }

        }
        else
        {
            imgLogo.Visible = false;
            divProviderInfo.InnerHtml = "Provider - CompareXpress";
            litTitlePage.Text = "Provider - CompareXpress";
            hplLogInOut.Text = "Sign In";
            hplChangePassword.Visible = false;
            hplLogInOut.NavigateUrl = "~/Provider/ProviderSecureLogin.aspx";
        }
    }
}
